home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / GIMP 2.6.8 / gimp-2.6.8-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / burn-in-anim.scm < prev    next >
Text File  |  2009-12-15  |  9KB  |  238 lines

  1. ;
  2. ;  burn-in-anim.scm V2.1  -  script-fu for GIMP 1.1 and higher
  3. ;
  4. ;  Copyright (C) 9/2000  Roland Berger
  5. ;  roland@fuchur.leute.server.de
  6. ;  http://fuchur.leute.server.de
  7. ;
  8. ;  Let text appear and fade out with a "burn-in" like SFX.
  9. ;  Works on an image with a text and a background layer
  10. ;
  11. ;  Copying Policy:  GNU Public License http://www.gnu.org
  12. ;
  13.  
  14. (define (script-fu-burn-in-anim org-img
  15.                                 org-layer
  16.                                 glow-color
  17.                                 fadeout
  18.                                 bl-width
  19.                                 corona-width
  20.                                 after-glow
  21.                                 show-glow
  22.                                 optimize
  23.                                 speed)
  24.  
  25.   (let* (
  26.         ;--- main variable: "bl-x" runs from 0 to layer-width
  27.         (bl-x 0)
  28.         (frame-nr 0)
  29.         (img 0)
  30.         (source-layer 0)
  31.         (bg-source-layer 0)
  32.         (source-layer-width 0)
  33.         (bg-layer 0)
  34.         (bg-layer-name 0)
  35.         (bl-layer 0)
  36.         (bl-layer-name 0)
  37.         (bl-mask 0)
  38.         (bl-layer-width 0)
  39.         (bl-height 0)
  40.         (bl-x-off 0)
  41.         (bl-y-off 0)
  42.         (nofadeout-bl-x-off 0)
  43.         (nofadeout-bl-width 0)
  44.         (blended-layer 0)
  45.         (img-display 0)
  46.         )
  47.  
  48.     (if (< speed 1)
  49.         (set! speed (* -1 speed)) )
  50.  
  51.     ;--- check image and work on a copy
  52.     (if (and (= (car (gimp-image-get-layers org-img)) 2)
  53.              (= (car (gimp-image-get-floating-sel org-img)) -1))
  54.  
  55.         ;--- main program structure starts here, begin of "if-1"
  56.         (begin
  57.           (gimp-context-push)
  58.  
  59.           (set! img (car (gimp-image-duplicate org-img)))
  60.           (gimp-image-undo-disable img)
  61.           (if (> (car (gimp-drawable-type org-layer)) 1 )
  62.               (gimp-image-convert-rgb img))
  63.           (set! source-layer    (aref (cadr (gimp-image-get-layers img)) 0 ))
  64.           (set! bg-source-layer (aref (cadr (gimp-image-get-layers img)) 1 ))
  65.           (set! source-layer-width (car (gimp-drawable-width  source-layer)))
  66.  
  67.           ;--- hide layers, cause we want to "merge visible layers" later
  68.           (gimp-drawable-set-visible source-layer FALSE)
  69.           (gimp-drawable-set-visible bg-source-layer     FALSE)
  70.  
  71.           ;--- process image horizontal with pixel-speed
  72.           (while (< bl-x (+ source-layer-width bl-width))
  73.               (set! bl-layer (car (gimp-layer-copy source-layer TRUE)))
  74.               (set! bl-layer-name (string-append "fr-nr"
  75.                                                  (number->string frame-nr 10) ) )
  76.  
  77.               (gimp-image-add-layer img bl-layer -2)
  78.               (gimp-drawable-set-name bl-layer bl-layer-name)
  79.               (gimp-drawable-set-visible bl-layer TRUE)
  80.               (gimp-layer-set-lock-alpha bl-layer TRUE)
  81.               (gimp-layer-add-alpha bl-layer)
  82.  
  83.               ;--- add an alpha mask for blending and select it
  84.               (gimp-selection-layer-alpha bl-layer)
  85.               (set! bl-mask (car (gimp-layer-create-mask bl-layer ADD-BLACK-MASK)))
  86.               (gimp-layer-add-mask bl-layer bl-mask)
  87.  
  88.               ;--- handle layer geometry
  89.               (set! bl-layer-width source-layer-width)
  90.               (set! bl-height      (car (gimp-drawable-height bl-layer)))
  91.               (set! bl-x-off (- bl-x     bl-width))
  92.               (set! bl-x-off (+ bl-x-off (car  (gimp-drawable-offsets bl-layer))))
  93.               (set! bl-y-off             (cadr (gimp-drawable-offsets bl-layer)))
  94.  
  95.               ;--- select a rectangular area to blend
  96.               (gimp-rect-select img bl-x-off bl-y-off bl-width bl-height CHANNEL-OP-REPLACE 0 0)
  97.               ;--- select at least 1 pixel!
  98.               (gimp-rect-select img bl-x-off bl-y-off (+ bl-width 1) bl-height CHANNEL-OP-ADD 0 0)
  99.  
  100.               (if (= fadeout FALSE)
  101.                   (begin
  102.                     (set! nofadeout-bl-x-off (car (gimp-drawable-offsets bl-layer)))
  103.                     (set! nofadeout-bl-width (+ nofadeout-bl-x-off bl-x))
  104.                     (set! nofadeout-bl-width (max nofadeout-bl-width 1))
  105.                     (gimp-rect-select img nofadeout-bl-x-off bl-y-off
  106.                                       nofadeout-bl-width bl-height
  107.                                       CHANNEL-OP-REPLACE 0 0)
  108.                   )
  109.               )
  110.  
  111.               ;--- alpha blending text to trans (fadeout)
  112.               (gimp-context-set-foreground '(255 255 255))
  113.               (gimp-context-set-background '(  0   0   0))
  114.               (if (= fadeout TRUE)
  115.                   (begin
  116.                     ; blend with 20% offset to get less transparency in the front
  117.                     (gimp-edit-blend bl-mask FG-BG-RGB-MODE NORMAL-MODE
  118.                                      GRADIENT-LINEAR 100 20 REPEAT-NONE FALSE
  119.                                      FALSE 0 0 TRUE
  120.                                      (+ bl-x-off bl-width) 0 bl-x-off 0)
  121.                   )
  122.               )
  123.  
  124.               (if (= fadeout FALSE)
  125.                   (begin
  126.                     (gimp-context-set-foreground '(255 255 255))
  127.                     (gimp-edit-bucket-fill bl-mask FG-BUCKET-FILL NORMAL-MODE
  128.                                            100 255 0 0 0)
  129.                   )
  130.               )
  131.  
  132.               (gimp-layer-remove-mask bl-layer MASK-APPLY)
  133.  
  134.               ;--- add bright glow in front
  135.               (if (= show-glow TRUE)
  136.                   (begin
  137.                     ;--- add some brightness to whole text
  138.                     (if (= fadeout TRUE)
  139.                         (gimp-brightness-contrast bl-layer 100 0)
  140.                     )
  141.  
  142.           ;--- blend glow color inside the letters
  143.           (gimp-context-set-foreground glow-color)
  144.           (gimp-edit-blend bl-layer FG-TRANSPARENT-MODE NORMAL-MODE
  145.                    GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
  146.                    FALSE 0 0 TRUE
  147.                    (+ bl-x-off bl-width) 0
  148.                    (- (+ bl-x-off bl-width) after-glow) 0)
  149.  
  150.           ;--- add corona effect
  151.           (gimp-selection-layer-alpha bl-layer)
  152.           (gimp-selection-sharpen img)
  153.           (gimp-selection-grow img corona-width)
  154.           (gimp-layer-set-lock-alpha bl-layer FALSE)
  155.           (gimp-selection-feather img corona-width)
  156.           (gimp-context-set-foreground glow-color)
  157.           (gimp-edit-blend bl-layer FG-TRANSPARENT-MODE NORMAL-MODE
  158.                    GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
  159.                    FALSE 0 0 TRUE
  160.                    (- (+ bl-x-off bl-width) corona-width) 0
  161.                    (- (+ bl-x-off bl-width) after-glow) 0)
  162.                   )
  163.               )
  164.  
  165.               ;--- merge with bg layer
  166.               (set! bg-layer (car (gimp-layer-copy bg-source-layer FALSE)))
  167.               (gimp-image-add-layer img bg-layer -1)
  168.               (gimp-image-lower-layer img bg-layer)
  169.               (set! bg-layer-name (string-append "bg-"
  170.                                                  (number->string frame-nr 10)))
  171.               (gimp-drawable-set-name bg-layer bg-layer-name)
  172.               (gimp-drawable-set-visible bg-layer TRUE)
  173.               (set! blended-layer (car (gimp-image-merge-visible-layers img
  174.                                         CLIP-TO-IMAGE)))
  175.               ;(set! blended-layer bl-layer)
  176.               (gimp-drawable-set-visible blended-layer FALSE)
  177.  
  178.               ;--- end of "while" loop
  179.               (set! frame-nr (+ frame-nr 1))
  180.               (set! bl-x     (+ bl-x speed))
  181.           )
  182.  
  183.           ;--- finalize the job
  184.           (gimp-selection-none img)
  185.           (gimp-image-remove-layer img    source-layer)
  186.           (gimp-image-remove-layer img bg-source-layer)
  187.  
  188.           (gimp-image-set-filename img "burn-in")
  189.  
  190.           (if (= optimize TRUE)
  191.               (begin
  192.                 (gimp-image-convert-indexed img 1 WEB-PALETTE 250 FALSE TRUE "")
  193.                 (set! img-out (car (plug-in-animationoptimize RUN-NONINTERACTIVE
  194.                                                               img
  195.                                                               bl-layer)))
  196.               )
  197.           )
  198.  
  199.           (gimp-drawable-set-visible (aref (cadr (gimp-image-get-layers img)) 0)
  200.                                   TRUE)
  201.           (gimp-image-undo-enable img)
  202.           (gimp-image-clean-all img)
  203.           (set! img-display (car (gimp-display-new img)))
  204.  
  205.           (gimp-displays-flush)
  206.  
  207.           (gimp-context-pop)
  208.         )
  209.  
  210.         ;--- false form of "if-1"
  211.         (gimp-message _"The Burn-In script needs two layers in total. A foreground layer with transparency and a background layer.")
  212.     )
  213.   )
  214. )
  215.  
  216.  
  217. (script-fu-register "script-fu-burn-in-anim"
  218.     _"B_urn-In..."
  219.     _"Create intermediate layers to produce an animated 'burn-in' transition between two layers"
  220.     "Roland Berger roland@fuchur.leute.server.de"
  221.     "Roland Berger"
  222.     "January 2001"
  223.     "RGBA GRAYA INDEXEDA"
  224.     SF-IMAGE    "The image"            0
  225.     SF-DRAWABLE "Layer to animate"     0
  226.     SF-COLOR   _"Glow color"           "white"
  227.     SF-TOGGLE  _"Fadeout"              FALSE
  228.     SF-VALUE   _"Fadeout width"        "100"
  229.     SF-VALUE   _"Corona width"         "7"
  230.     SF-VALUE   _"After glow"           "50"
  231.     SF-TOGGLE  _"Add glowing"          TRUE
  232.     SF-TOGGLE  _"Prepare for GIF"      FALSE
  233.     SF-VALUE   _"Speed (pixels/frame)" "50"
  234. )
  235.  
  236. (script-fu-menu-register "script-fu-burn-in-anim"
  237.                          "<Image>/Filters/Animation/Animators")
  238.